from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class editor_logic_state_editing_query_fake :
    def __init__ ( self ) :
        self . _activate_editor_state_editing_query = False
        self . _on_key_ctrl_f5 = False
        self . _on_key_f5 = False
        self . _on_key_return = False
        self . _on_key_backspace = False
        self . _new_kb_type_added = None
        self . _set_greater_common_kb_types_part = None
        self . _receive_is_any_marks_left_in_editor_contents = None
        self . _hide_editor = False
    def activate_editor_state_editing_query ( self ) :
        self . _activate_editor_state_editing_query = True
    def new_kb_type_added ( self , kb_type ) :
        self . _new_kb_type_added = kb_type
    def set_greater_common_kb_types_part ( self , part ) :
        self . _set_greater_common_kb_types_part = part
    def receive_is_any_marks_left_in_editor_contents ( self , any_marks ) :
        self . _receive_is_any_marks_left_in_editor_contents = any_marks
    def on_key_ctrl_f5 ( self ) :
        self . _on_key_ctrl_f5 = True
    def on_key_f5 ( self ) :
        self . _on_key_f5 = True
    def on_key_return ( self ) :
        self . _on_key_return = True
    def on_key_backspace ( self ) :
        self . _on_key_backspace = True
    def hide_editor ( self ) :
        self . _hide_editor = True

class arbitrary_module_fake :
    def on_key_ctrl_f5 ( self ) :
        pass
    def on_key_f5 ( self ) :
        pass
    def on_key_return ( self ) :
        pass
    def on_key_backspace ( self ) :
        pass
    def new_kb_type_added ( self , kb_type ) :
        pass
    def set_greater_common_kb_types_part ( self , part ) :
        pass
    def receive_is_any_marks_left_in_editor_contents ( self , any_marks ) :
        pass
    def hide_editor ( self ) :
        pass

class mediator_editor_logic_state_editing_query_tests : 
    'mediator_editor_logic_state_editing_query'
    def __init__ ( self , test ) :
        self . _test = test
        self . _editor_logic_state_editing_query = editor_logic_state_editing_query_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'editor_logic_state_editing_query' 
            , self . _editor_logic_state_editing_query
            , arbitrary_module_fake
            ) )
    def test_activate_editor_state_editing_query ( self ) :
        self . _mediator . activate_editor_state_editing_query ( )
        self . _test . assume_true ( self . _editor_logic_state_editing_query . _activate_editor_state_editing_query )
    def test_on_key_ctrl_f5 ( self ) :
        self . _mediator . on_key_ctrl_f5 ( )
        self . _test . assume_true ( self . _editor_logic_state_editing_query . _on_key_ctrl_f5 )
    def test_on_key_f5 ( self ) :
        self . _mediator . on_key_f5 ( )
        self . _test . assume_true ( self . _editor_logic_state_editing_query . _on_key_f5 )
    def test_on_key_return ( self ) :
        self . _mediator . on_key_return ( )
        self . _test . assume_true ( self . _editor_logic_state_editing_query . _on_key_return )
    def test_on_key_backspace ( self ) :
        self . _mediator . on_key_backspace ( )
        self . _test . assume_true ( self . _editor_logic_state_editing_query . _on_key_backspace )
    def test_new_kb_type_added ( self ) :
        self . _mediator . new_kb_type_added ( 'my type' )
        self . _test . assume_equal ( self . _editor_logic_state_editing_query . _new_kb_type_added , 'my type' )
    def test_set_greater_common_kb_types_part ( self ) :
        self . _mediator . set_greater_common_kb_types_part ( 'my part' )
        self . _test . assume_equal ( self . _editor_logic_state_editing_query . _set_greater_common_kb_types_part , 'my part' )
    def test_receive_is_any_marks_left_in_editor_contents ( self ) :
        self . _mediator . receive_is_any_marks_left_in_editor_contents ( 'my marks' )
        self . _test . assume_equal ( self . _editor_logic_state_editing_query . _receive_is_any_marks_left_in_editor_contents , 'my marks' )
    def test_hide_editor ( self ) :
        self . _mediator . hide_editor ( )
        self . _test . assume_true ( self . _editor_logic_state_editing_query . _hide_editor )
